package com.prs.crm.service.oa.impl;

import java.io.File;
import java.util.List;

import com.prs.crm.context.Attach;
import com.prs.crm.context.Constrains;
import com.prs.crm.context.FileUtil;
import com.prs.crm.dao.oa.VehicleDao;
import com.prs.crm.domain.oa.Vehicle;
import com.prs.crm.service.impl.BaseServiceImpl;
import com.prs.crm.service.oa.VehicleService;

public class VehicleServiceImpl extends BaseServiceImpl<Vehicle,VehicleDao> implements VehicleService{

	@Override
	public List<Vehicle> getVehicleAll() {
		// TODO Auto-generated method stub
		return this.getDao().getAllVehicle();
	}
	@Override
	public void saveVehicle(Vehicle vehicle, File file, String fileName) {
		vehicle.setAttach(FileUtil.getInstance().createAttach(file, fileName));
		this.getDao().save(vehicle);
		
	}

	@Override
	public void saveVehicles(Vehicle vehicle, File file, String fileName) {
		 Attach cAttach=FileUtil.getInstance().saveFile(file, fileName,"",Constrains.UPLOAD_DIR_VEHICLET);
			
			if(cAttach.getSrc()!=null){
				vehicle.setVehicle_file(cAttach.getSrc());
			}
			this.getDao().save(vehicle);
		
	}

}
